{literal}
    <script type="text/javascript">

      function suggestion (_num) {
        
        $("#textbox"+_num).focus().autocomplete(cities);
      }
    </script>
{/literal}
    
<div id="main_container">

    {$oZoneHeader}
    
    <div class="main_content">
        {$oZoneTopMenu}
        <div class="center_content">  
            <div class="left_content">
                {$oZoneLeftMenu}
            </div>


          <form action="{jurl 'annonce~BoEquipement:sauvegarder'}" method="POST">
           <input type="hidden" name="id" value="{$id}" />
           <input type="hidden" name="idCateg" value="{$idCateg}" />
            <div id="editCompte" class="right_content">
                {if $equipement->id_equipement}
                    <h2>Modification - {$categorie->lib_categ_equipement}</h2> 
                {else}
                    <h2>Ajout  - {$categorie->lib_categ_equipement}</h2> 
                {/if}
                    
                     <dl>
                        <dt><label>Libell&eacute; : </label></dt>
                        <dd><input  type="text" id="libelle" name="libelle" value="{$equipement->lib_equipement}" /></dd>
                        
                    </dl>

               
                            <div id='TextBoxesGroup'>
                            {if $id && sizeof($equipement->lib_choix)}
                                
                                {foreach $equipement->lib_choix as $k=>$item}
                                <div id="TextBoxDiv{$k}">
                                    {if !$k}
                                        <label>Choix : </label>
                                    {else}
                                        <label>&nbsp;</label>
                                    {/if}
                                    <input class="suggest" type="text" name="textbox{$k}" id="textbox{$k}" value="{$item}" onfocus="suggestion({$k})" />
                                    <input num="{$k}" type="button" value="Supprimer" class="removeButton" onclick="removebtn({$k})" />
                                    </div>
                                {/foreach}
                                
                            {else}
                            
                              <div id="TextBoxDiv1">
                                <label>Choix : </label>
                                <input class="suggest" type='text' id='textbox' name="textbox"/>
                              </div>
                              {/if}
                            </div>
                    
                            <div class="rbtn"><input type='button' value='Ajouter' id='addButton'></div>
                   
                   <div></div>
                    <dl class="submit">
                        <input class="valider" title="Valider" type="submit" value="" />
                        <a title="Annuler" href="{jurl 'annonce~BoEquipement:index'}" class="bt_green"><span class="bt_green_lft"></span><strong>Annuler</strong><span class="bt_green_r"></span></a>
                    </dl>
                   
            </div><!-- end of right content-->
         </form>
        </div>   <!--end of center content -->               

        <div class="clear"></div>
    </div> <!--end of main content-->
    
    
    <div class="footer">
    </div>

</div>   
<!-- Script autocompletion--> 
{literal}
    <script type="text/javascript">


    var cities = {/literal}{$listechoix}{literal};

    $(".suggest").focus().autocomplete(cities);
    
     </script>
{/literal}


<!-- Script for add_remove content-->   
{literal}
    <script type="text/javascript">
    function removebtn (_num) {
        $("#TextBoxDiv"+_num).remove();
    }
    
    $(function () {   
     var counter = 2;
        $("#addButton").click(function () {
        var newTextBoxDiv = $(document.createElement('div'))
             .attr("id", 'TextBoxDiv' + counter);
     
        newTextBoxDiv.after().html('<label>' + ' &nbsp; </label>' +
              '<input class="suggest" type="text" name="textbox' + counter + 
              '" id="textbox' +counter + '" value="" onfocus="suggestion('+counter+')">'+
              '<input num='+ counter +' type="button" value="Supprimer' +
              '" class="removeButton' + '" onclick="removebtn('+counter+')">'
              
              );
     
        newTextBoxDiv.appendTo("#TextBoxesGroup");
     
        counter++;
         });
     
         $(".removeButton").bind('click', function () {
            var num = $(this).attr('num'); 
            $("#TextBoxDiv"+num).remove();
     
         });
     
         $("#getButtonValue").click(function () {
     
        var msg = '';
        for(i=1; i<counter; i++){
          msg += "\n Textbox #" + i + " : " + $('#textbox' + i).val();
        }
              alert(msg);
         });
    });
    </script>
{/literal}
